
public class ControlLambda extends ControlElement {

	/*
	 * this is the pointer to the control delta which holds the contents of this lambda
	 */
	
	int deltaPointer;
	boolean hasComma =false;
	String identifier;
	String commaIdentifier[];
	
	public ControlLambda(int newLambdaPointer, STNode leftChild) {
		super("lambda");
		this.deltaPointer = newLambdaPointer;
		if (leftChild.content.equals(",")){
			handleComma(leftChild);
			hasComma = true;
		}else{
			assert(leftChild.childArray.length == 0):"ControlLambda: lambda left child must have no children";
			assert(leftChild.content.contains("<ID:")):"ControlLambda: lambda left child must be an <ID:";
			identifier = extractID(leftChild.content);
		}
		
	}
	
	private String extractID(String content) {
		String temp = content.split(":")[1];
		return temp.substring(0, temp.length()-1);
	}

	private void handleComma(STNode leftChild) {
		commaIdentifier = new String[leftChild.childArray.length];
		for(int i = 0 ; i < leftChild.childArray.length ; i++){
			commaIdentifier[i] = extractID(leftChild.childArray[i].content);
		}
	}

	/*
	 *  lambda:delta#:x:y:z 
	 */
	@Override
	public String toString() {
		if (hasComma){
			String str = "lambda:"+deltaPointer + ":multivar";
			for(int i = 0 ; i < commaIdentifier.length ; i++){
				str +=  ":" + commaIdentifier[i];
			}
			return str;
		}else{
			return "lambda:" + deltaPointer + ":" + identifier;
		}
	}

	public static void main(String[] args) {
		
	}

}
